import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'

const originPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Main',
    component: Main,
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/Home/Home.vue')
      }, {
        path: '/mall',
        name: 'mall',
        component: () => import('@/views/Mall/My.vue')
      }, {
        path: '/user',
        name: 'user',
        component: () => import('@/views/User/User.vue')
      }, {
        path: '/event',
        name: 'event',
        component: () => import('@/views/Event/Event.vue')
      },
       {
        path: '/test',
        name: 'test',
        component: () => import('@/views/Test.vue')
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    /* webpackChunkName: "about" */
    component: () => import('@/views/About.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
